package com.common.base;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 * 
 */
public class PageResult implements Serializable {
	private static final long serialVersionUID = 1L;

	//每页记录数
	private int pageSize;
	//当前页数
	private int pageIndex;
	//总条数
	private Long total;
	//列表数据
	private List<?> list;

	public PageResult(int pageSize, int indexPage, Long total, List<?> list) {
		this.pageSize = pageSize;
		this.pageIndex = indexPage;
		this.total = total;
		this.list = list;
	}

	public static PageResult setResult(Page<?> result){
		return new PageResult(result.getPageSize(),result.getPageNum(),result.getTotal(),result.getResult());
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}
}
